<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<?php
  $n3='';
  $n1 ='';
  $n2 = '';
  if(isset($_POST['submit1'])){
  $n1 = $_POST['num1'];
  $n2 = $_POST['zhuanhuan'];
  
       if($_POST['zhuanhuan']=='10to2'){
           $n3 = decbin($n1);
       };
       if($_POST['zhuanhuan']=='10to8'){
           $n3 = decoct($n1);
       };
       if($_POST['zhuanhuan']=='10to16'){
        $n3 = dechex($n1);
    };

  }
?>
<body>
    <form action="" method="post">
        <input type="text" name="num1" value="<?php echo $n1;?>">
        <select name="zhuanhuan" id="">
            <option value="10to2">10to2</option>
            <option value="10to8" <?php if( $n2=='10to8') echo "selected"?>>10to8</option>
            <option value="10to16" <?php if( $n2=='10to16') echo "selected"?>>10to16</option>
        </select>
        <input type="submit" value="转换" name="submit1">
        <input type="text" value="<?php echo $n3;?>">
    </form>
</body>
</html>
